package com.smarthealthring.mm.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.jakewharton.rxbinding2.view.RxView;
import com.smarthealthring.mm.R;
import com.smarthealthring.mm.base.BaseActivity;
import com.smarthealthring.mm.base.IPresenter;
import com.smarthealthring.mm.utils.ComToolBar;
import com.smarthealthring.mm.utils.SPUtils;
import com.xw.repo.BubbleSeekBar;

import butterknife.BindView;

/**
 * 设备类型列表
 * Created by bilibili on 2018/5/15.
 */

public class SportTagetActivity extends BaseActivity {

    @BindView(R.id.bsb_sport_tar)
    BubbleSeekBar mBsbSportTar;
    @BindView(R.id.tv_sport_tar)
    TextView mTvSportTar;

    int progressFinal;

    @Override
    protected void initComToolBar() {
        ImageView ivLeft = ComToolBar.setleftImg(mContext, R.drawable.back_white);
        RxView.clicks(ivLeft)
                .subscribe(o -> finish());
        ComToolBar.setTitle(mContext, "运动目标设定");
    }

    @Override
    protected int getLayout() {
        return R.layout.act_sport_target;
    }

    @Override
    protected void initEventAndData(@Nullable Bundle savedInstanceState) {
        int spSport = SPUtils.getInt(SPUtils.SPORT_TARGET, 8);
        mTvSportTar.setText(spSport * 1000 + "步");
        Log.e("defualt_sport===", spSport + "");
        mBsbSportTar.setProgress(spSport);

        mBsbSportTar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
            @Override
            public void onProgressChanged(BubbleSeekBar bubbleSeekBar4, int progress, float progressFloat) {
                mTvSportTar.setText(progress * 1000 + "步");
                progressFinal = progress;
                SPUtils.setInt(SPUtils.SPORT_TARGET, progressFinal);
            }

            @Override
            public void getProgressOnActionUp(BubbleSeekBar bubbleSeekBar4, int progress, float progressFloat) {

            }

            @Override
            public void getProgressOnFinally(BubbleSeekBar bubbleSeekBar4, int progress, float progressFloat) {
            }
        });
    }

    @Override
    protected IPresenter createPresenter() {
        return null;
    }

}
